package utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

public class JarReader {
    /**
     * 获取jar包中的配置文件 (web.xml)
     * @param jarPath
     * @param file
     * @return
     */
    public static InputStream readFromJar(String jarPath, String file) {
        JarFile jarFile = null;
        try {
            jarFile = new JarFile(jarPath);
            JarEntry jarEntry = jarFile.getJarEntry(file);
            InputStream inputStream = jarFile.getInputStream(jarEntry);
            return inputStream;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
